<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>注册</title>
	<link rel="stylesheet" type="text/css" href="/build/css/base.css"/>
	<link rel="stylesheet" type="text/css" href="/build/css/main.css">
	<script src="/build/public/vue.js" charset="utf-8"></script>
	<script src="/build/public/vue-resource.js" charset="utf-8"></script>
	<script src="/build/js/jquery.min.js"></script>
	<script src="/build/js/global.js"></script>
</head>
<body style="background:#fff;">
	<div id="container" style="padding-bottom:50px;">
		<div class="password-con register-con">
			<!-- <div class="pass-iconfont"><input type="tel" placeholder="请输入邀请码" v-model='invitationCode' class="inviteCode" name="inviteCode" maxlength="6"></div> -->
			<div class="pass-iconfont dis-pass">
				<input type="tel" placeholder="请输入手机号" maxlength="11" v-model='phoneNum' @click="disPass" class="mobile-dis">
			</div>
			<div class="pass-iconfont dis-pass">
				<input type="tel" placeholder="请输入验证码" v-model='verificationCode' @click="disPass" style="float:left;width:60%;" maxlength="6">
				<span class="tel-code" style="margin:15px 0 0 0;" v-on:click='send()'>发送验证码</span>
			</div>
			<div class="pass-iconfont dis-pass pass-iconfont1">
				<input type="password" placeholder="请设置登录密码" v-model='password' name="password" id="password" maxlength="18" @click="disPass">
			</div>
			<div class="pass-iconfont dis-pass pass-iconfont2">
				<input type="password" placeholder="请再次输入登录密码" v-model='passwordCon' name="password" id="password" maxlength="18" @click="disPass">
			</div>
			<p style="display:none;margin-right: 15px;" class="pass-none">两次密码输入不一致</p>
		</div>
		<div class="register-text" id="checkbox" style="text-align:left;">
			<img src="../../build/images/select.png" alt="" width="16" height="16" class="iconfont1  checkbox"><img src="../../build/images/noselect.png" alt="" width="16" height="16" class="iconfont2 checkbox" style="display:none;">
			已阅读并同意<span class="blue" style="color:#005d9e;">《用户使用及安全隐私协议》</span>
		</div>
		<div class="login-btn">
			<button @click="register" class="resgiter-btn">完成注册</button>
		</div>
	</div>
<script src="/build/js/config.js" charset="utf-8"></script>
<script src="/build/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
var vm = new Vue({
	el:"#container",
	data:{
		invitationCode:'',
		phoneNum:'',
		verificationCode:'',
		password:'',
		passwordCon:'',
	},
	mounted:function(){
		this.$nextTick(function(){
			$('.blue').click(function(event) {
				window.location.href="agreement.html"
			});
			/*$('.inviteCode').on('input', function(e) {
			    var number = 6;
			    var pw = $("input[name = 'inviteCode']").val();
			    if(pw.length==6){
			    	if(vm.invitationCode!=''){
					$('.dis-pass input').removeAttr('disabled');

					$('#password').blur(function(event) {
						if(fomatPass(vm.password)){
						}else{
							toast('密码必须由6-18位字母与数字组成')
						}
					});
					get('/user/invitor-code/exists',{invitationCode:vm.invitationCode},function(res){
					});
				}
			    }
			});*/
			/*$('.inviteCode').blur(function(event) {
				
			});*/
		})
	},
	methods:{
		// 发送验证码
		send:function(){
			if($('.tel-code').css('color')!='rgb(102, 102, 102)'){
				post('/user/send/mobile-code',{mobile:vm.phoneNum,check:false,registerCheck:true},function(res){
					$('.tel-code').css({'background':'#eee',color:'#666'});
					toast('验证码已发送，请注意查收')
					$('.password-send').css({'background':'#999',color:'#fff','border':'1px solid #999'});
					var validCode=true;
					if (validCode) {
						validCode=false;
						var time=60;
						var t=setInterval(function() {
							time--;
							$(".tel-code").html(time+"S后再次发送");
							if (time==0) {
								clearInterval(t);
							$(".tel-code").removeAttr('disabled').html("重新获取");
							$('.password-send').removeAttr('disabled').html("重新获取");
							$('.tel-code').css({'background':'rgba(0,93,158,0.2)','color':'#005d9e'});
							$('.password-send').css({'background':'rgba(0,93,158,0.2)','color':'#005d9e','border':'1px solid #005d9e'});
								validCode=true;
							}
						},1000)
					}
				})
			}
		},
		// 注册按钮
		register:function(){
			var $this = this;
			if($('.iconfont2').css('display')=='none'){
				post('/user/advisor/register',{
					mobile:this.phoneNum,
					password:this.password,
					verificationCode:this.verificationCode,
					// invitationCode:this.invitationCode,
				},function(res){
					window.localStorage.setItem(siteTokenKey,res.data.token)
					post('/user/login',{
						mobile:vm.phoneNum,
						password:vm.password
					},function(res){
						window.localStorage.setItem(siteTokenKey,res.data.token)
						toast(res.data.name+'注册成功');
						setTimeout(function(){
							window.location.href='/index.html'
						},1500)
					});
				});
			}else{
				toast('请先阅读并同意《用户使用及安全隐私协议》')
			}
		},
		disPass:function(){
			/*if(vm.invitationCode==''){
				alert('请先填写邀请码');
				$('.dis-pass input').attr({'disabled':'disabled'});
			}*/
		},
	}
})
</script>
</body>
</html>
